import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { WarehouseStockVO, WarehouseStockForm, WarehouseStockQuery } from '@/api/lingxing/warehouseStock/types';

/**
 * 查询领星仓库库存列表
 * @param query
 * @returns {*}
 */

export const listWarehouseStock = (query?: WarehouseStockQuery): AxiosPromise<WarehouseStockVO[]> => {
  return request({
    url: '/lingxing/warehouseStock/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询领星仓库库存详细
 * @param id
 */
export const getWarehouseStock = (id: string | number): AxiosPromise<WarehouseStockVO> => {
  return request({
    url: '/lingxing/warehouseStock/' + id,
    method: 'get'
  });
};

/**
 * 新增领星仓库库存
 * @param data
 */
export const addWarehouseStock = (data: WarehouseStockForm) => {
  return request({
    url: '/lingxing/warehouseStock',
    method: 'post',
    data: data
  });
};

/**
 * 修改领星仓库库存
 * @param data
 */
export const updateWarehouseStock = (data: WarehouseStockForm) => {
  return request({
    url: '/lingxing/warehouseStock',
    method: 'put',
    data: data
  });
};

/**
 * 删除领星仓库库存
 * @param id
 */
export const delWarehouseStock = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lingxing/warehouseStock/' + id,
    method: 'delete'
  });
};

/**
 * 同步领星接口
 * @returns {*}
 */
export const syncData = () => {
  return request({
    url: '/lingxing/warehouseStock/syncData',
    method: 'post'
  });
};

export const getNewestUpdateTime = () => {
  return request({
    url: '/lingxing/warehouseStockRealTime/getNewestUpdateTime',
    method: 'get'
  });
};
